package com.h1909d.weinfo.model;

import com.h1909d.weinfo.base.BaseModel;
import com.h1909d.weinfo.bean.NewsDetailBean;
import com.h1909d.weinfo.net.HttpUtil;
import com.h1909d.weinfo.net.ResultCallBack;
import com.h1909d.weinfo.net.ResultSubscriber;
import com.h1909d.weinfo.net.RxUtils;

public class NewsDetailModel extends BaseModel {

    public void getNewsDetail(int newsId, final ResultCallBack<NewsDetailBean> callBack){
        addDisposable(
                HttpUtil.getInstance()
                .getZhihuService()
                .getNewsDetail(newsId)
                .compose(RxUtils.<NewsDetailBean>rxSchedulerHelper())
                .subscribeWith(new ResultSubscriber<NewsDetailBean>() {
                    @Override
                    public void onNext(NewsDetailBean newsDetailBean) {
                        callBack.onSuccess(newsDetailBean);
                    }
                })
        );
    }
}